package kr.hkit.powerjava.chapter24;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class CopyFileStream {
	public static void main(String[] args) {
		FileInputStream fis = null;
		FileOutputStream fos = null;
		long start,end;
		try {
			fis = new FileInputStream("input2.txt");
			fos = new FileOutputStream("output2.txt");
			start = System.currentTimeMillis();
			int c;
			while( (c=fis.read()) !=-1){
				System.out.printf("%s",(char)c);
				fos.write(c);
			}
			end=System.currentTimeMillis();
			System.out.println();
			System.out.println("걸린시간"+(end-start));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			if(fis !=null){
				try{fis.close();}catch(Exception e){}
			}
			if(fos !=null){
				try{fos.close();}catch(Exception e){}
			}
		}
	}
}
